home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compendium Deluxe 2
/
LSD and 17bit Compendium Deluxe - Volume II.iso
/
a
/
prog
/
misc
/
bumpseq371.lha
/
BumpSeq
/
BumpSeq.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-12-04
|
2KB
|
129 lines
/****** BumpSeq.c *************************************************************
*
* $VER: BumpSeq.c 37.1 (4.12.94) -- Copyright © 1994 Magnetic Ink
*
*
* SYNOPSIS
* Nothing fancy -- just a quick hack to bump a specified seqFile.
* SeqFile(s) should be protected by semaphores or lockfiles, but
* for now I'll make do with this...
*
* COPYRIGHT
* BumpSeq and its source are Copyright © 1994 Magnetic Ink, but
* are freely redistributable for non-profit purposes.
*
* NOTES
* Compiled with DICE v3.0
*
* AUTHOR
* Snail:
* ¯¯¯¯¯¯
* Klaus Alexander Seistrup
* Ahornsgade 8A¹
* DK-2200 København N
* DENMARK
*
* EMail:
* ¯¯¯¯¯¯
* kleis@mink.ping.dk
*
*******************************************************************************/
#include "BumpSeq.h"
/*
**
** USAGE: BumpSeq <seqFile> [Quiet]
**
*/
Prototype LONG BumpSeq(VOID);
//
LONG
BumpSeq(VOID)
{
LONG RC = RETURN_FAIL;
LIB *SysBase = *((LIB **)4L);
LIB *DOSBase = OpenLibrary("dos.library",37L);
if (DOSBase)
{
ARG *DObj = (ARG *) AllocDosObject(DOS_RDARGS,NULL);
RC = RETURN_ERROR;
if (DObj)
{
ARG *RDArgs;
LONG ArgV[2];
ArgV[0] = ArgV[1] = 0L;
DObj->RDA_ExtHelp = EXTHELP;
RDArgs = ReadArgs(&(DObj->RDA_ExtHelp[TEMPLATE_OFFS]),ArgV,DObj);
if (RDArgs)
{
TEXT *seqFile = (TEXT *) ArgV[ARG_SEQFILE];
BPTR fh = Open(seqFile,MODE_OLDFILE);
if (fh == NULL)
fh = Open(seqFile,MODE_NEWFILE);
if (fh == NULL)
fh = Open(seqFile,MODE_READWRITE);
if (fh)
{
LONG oldVal;
Seek(fh,0L,OFFSET_BEGINNING);
if (Read(fh,(TEXT *)&oldVal,4L) != 4L)
oldVal = 0L;
Close(fh);
if (fh = Open(seqFile,MODE_NEWFILE))
{
LONG newVal = oldVal + 1L;
Write(fh,(TEXT *)&newVal,4L);
Close(fh);
if (!ArgV[ARG_QUIET])
VPrintf("%ld\n",&oldVal);
RC = RETURN_OK;
}
else
PrintFault(IoErr(),seqFile);
}
else
PrintFault(IoErr(),seqFile);
FreeArgs(RDArgs);
}
else
PrintFault(IoErr(),NULL);
FreeDosObject(DOS_RDARGS,DObj);
}
else
PrintFault(ERROR_NO_FREE_STORE,NULL);
CloseLibrary(DOSBase);
}
return (RC);
}
STXT VersTag[] = "$VER: " VSTR;
STXT Compiled[] = "Compiled on " __DATE__ " at " __TIME__;
STXT Copyright[] = "Copyright © 1994 Klaus Alexander Seistrup @ Magnetic Ink";
STXT EMail[] = "E-mail: kleis@mink.ping.dk";
/*
** EOF
*/